package finalgame.GUI.battle;

import org.newdawn.slick.UnicodeFont;
import org.newdawn.slick.opengl.Texture;

import finalgame.Game;
import finalgame.Engine.Battle;
import finalgame.Engine.pokemon.Pokemon;
import finalgame.Graphics.Location;
import finalgame.Graphics.Render2D;
import finalgame.Graphics.RenderEngine;
import finalgame.Graphics.RenderObj;

public class BattleScreen implements RenderObj {
	private int hometurf;	// Which type of pokemon has this battle as home turf
							// Not used
	private String type;			// Battle type
	private Pokemon a, b;			// Pokemon involved
	private BattleMenu menu;		// The menu used by this battle
	private Battle currentBattle;	// Current battle occuring in this screen
	private boolean firstUse;
	
	/**
	 * Init battlescreen
	 * @param type What type is the location
	 */
	public BattleScreen(int type) {
		hometurf = type;
		this.type = getClass().getSimpleName().toLowerCase();
	}
	
	/**
	 * Use this battlescreen for a battle
	 * @param battle
	 */
	public void use(Battle battle) {
		firstUse = true;
		menu = new BattleMenu(battle.getMe(), this);
		currentBattle = battle;
	}
	
	public Battle getBattle() {
		return currentBattle;
	}
	
	/**
	 * Render the battle
	 */
	public void render() {
		Texture bg = RenderEngine.getSprite(type + ".bg");
		Render2D.drawTexUncentered(20, 20, bg);
		if(menu != null)
			menu.render();
		currentBattle.getMyPokemon().render(new Location(80, 204), Pokemon.Direction.UP, true);
		currentBattle.getOpponentPokemon().render(new Location(425, 82), Pokemon.Direction.DOWN, false);
	}
	
	/**
	 * Update.
	 * Just forwards to the menu.
	 */
	public void update() {
//		if(firstUse) {
//			Game.game.jukebox.playSoundFX("battle.battle", 1, 1);
//			firstUse = false;
//		}
		menu.update();
	}
	
	/**
	 * Get where to render this.
	 */
	public Location getRenderLocation() {
		return new Location(20, 20);
	}
}
